package com.kehutong.auth.service;

import com.kehutong.auth.entity.TestDemo;
import org.coraframework.inject.Inject;
import org.coraframework.inject.Singleton;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.webservice.WebService;
import org.coraframework.orm.Pool;
import org.coraframework.orm.jdbc.JdbcSession;

//@WebService("/auth/account/service")
@Singleton
public class TestService {

    private static final Logger logger = LoggerFactory.getLogger(TestService.class);

    @Inject
    private JdbcSession jdbcSession;

    public Integer addTestData(){

        TestDemo testDemo = Pool.newInstance(TestDemo.class);
        testDemo.setName("今天");
        testDemo.setAge(99);
        testDemo.setDesc("this is demo!");
        int num = jdbcSession.insert(testDemo);

        logger.info("添加數據返回結果：{}",num);

        return num;
    }

    public TestDemo findTestData(String id){

        TestDemo num = jdbcSession.findById(TestDemo.class,id);

        logger.info("查詢數據：{}",num);

        return num;
    }

}
